package com.pshcp.doctor.api;


import com.framework.base.ResultBuilder;
import com.framework.base.ResultDTO;
import com.framework.exception.BizException;
import com.framework.logaop.Log;
import com.framework.logaop.LogSourceEnum;
import com.framework.logaop.LogTypeEnum;
import com.framework.thread.ReqComTool;
import com.pshcp.doctor.tool.DoctorDeptTool;
import com.pshcp.doctor.vo.doctordept.DoctorDeptVO;
import com.pshcp.domain.model.Dept;
import com.pshcp.service.DeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: TODO
 * @Author: xiaoche
 * @Date: 2022/11/8 20:53
 */
@Api(tags = {"医生端-医生科室接口"})
@Slf4j
@RestController
@RequestMapping("/api/doctor/doctorDept")
public class DoctorDeptAPI {

    @Autowired
    private DeptService deptService;

    @ApiOperation("获取医生所属科室列表")
    @Log(source = LogSourceEnum.APP, type = LogTypeEnum.SELECT, desc = "获取医生所属科室列表")
    @PostMapping("getDoctorDeptList")
    public ResultDTO<List<DoctorDeptVO>> getDoctorDeptList() throws BizException {
        List<Dept> deptList = deptService.getDeptListByDoctorId(ReqComTool.getUserId());
        List<DoctorDeptVO> list = DoctorDeptTool.buildGetDoctorDeptList(deptList);
        return ResultBuilder.success(list);
    }
}
